package com.chenc.unitdemo.jwt.interceptor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @ClassName
 * @Describtion:
 * @Author:Chenc
 * @Date:2023/12/18 15:22
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer{

    @Value("${cqk.interceptor.jwt:true}")
    private Boolean jwtInterceptorFlag;
    @Resource
    JWTInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        if (jwtInterceptorFlag){
            registry.addInterceptor(jwtInterceptor).excludePathPatterns("/login/**");
        }

        //这边的path实际是 urlpath
    }
}
